import 'dart:convert';
import 'package:base_flutter/base_flutter.dart';
import 'package:dio/dio.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_cupertino_date_picker_fork/flutter_cupertino_date_picker_fork.dart' as dt;
import 'package:ls_work/a_yyt/models/pending_entity.dart';
import 'package:ls_work/net/post_request.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/util/text_input_formatter.dart';
import 'package:ls_work/viewmodel/service_execute/service_execute_submit_widget.dart';


import '../../a_yyt/models/staff_group_entity.dart';
import '../../net/HttpUtil.dart';
import '../../net/api/http_api.dart';
import '../../res/styles.dart';

import '../../util/flat_button.dart';
import '../../widgets/add_image_widget.dart';
import '../../widgets/click_item.dart';
import '../../widgets/load_image.dart';

abstract class ServiceExecuteBaseViewModel<T> extends BaseListViewModel<T> {
  ServiceExecuteBaseViewModel(BuildContext context) : super(context);

  List<TextEditingController> textEditingControllers = [];
  DateTime _selectedDate = DateTime.now();
  String _selectedTime = '';
  TextEditingController textViewController = TextEditingController();
  String _todoTime =
      DateUtil.formatDate(DateTime.now(), format: DateFormats.y_mo_d);
  String _delayStaff = '';

  List<StaffGroupInfo> staffGroupList = [];
  List<StaffGroupInfo> staffList = [];

  int _serviceTypeId = 0;
  int? _humanId;
  int _bizId = 0;

  void onExecuteClick(int id) {
    ///服务计划=1057
    var map = {'id': id};
    showLoadingDialog();
    HttpUtil.instance
        .getDio()
        .post(HttpApi.servicePlanRecordDetail, data: map,options: PostRequest.urlencodedHeader)
        .then((r) {
      hideDialog();
      if (r.statusCode == 200) {
        Map<String, dynamic> map = json.decode(r.toString());
        if (map["code"].toString() == "0") {
          if (map['data'] != null) {
            PendingModel model = PendingModel.fromJson(map['data']);
            textEditingControllers = [];
            _selectedDate = DateTime.now();
            _selectedTime =
                ''; //DateUtil.formatDate(_selectedDate, format: DateFormats.full);
            textViewController.text = '';
            _bizId = id;
            if (model.resultMode == 0) {
              ///直接执行，不弹窗
              // _updateServicePlanRecord(isResultMode: true);
              _bottomServiceDoneSheetAlert(model);
              // showToast("我是直接执行");
              return;
            }
            _bottomServiceSheetAlert(model);
          } else {
            showToast(map["msg"]);
          }
        } else {
          showToast(map["msg"]);
        }
      } else {
        showToast(r.statusCode.toString());
      }
    }).catchError((e) {
      hideDialog();
      print(e.toString());
      showToast(getErrorMessage((e as DioError).type));
    });
  }

  ///服务执行页
  _bottomServiceSheetAlert(PendingModel model) async {
    var textFields = <Widget>[];
    if ((model.result??[]).length > 0) {
      model.result?.forEach((element) {
        var textEditingController = new TextEditingController();
        textEditingControllers.add(textEditingController);
        return textFields
            .add(_serviceItem(model, element, textEditingController));
      });
    }
    var files = <String>[];
    var voiceFileId = "";
    _selectedTime = DateTime.now().toDateStr(['yyyy','-','mm','-','dd',' ','HH',':','nn',':','ss']);
    await showModalBottomSheet(
      backgroundColor: Colors.white,
      context: context,
      isScrollControlled: true,
      isDismissible: false,
      builder: (BuildContext context) {
        return StatefulBuilder(
          builder: (context, setDialogState) {
            return Stack(
              children: <Widget>[
                SingleChildScrollView(
                  child: Container(
                    width: double.infinity,
                    padding: EdgeInsets.only(
                        bottom: MediaQuery.of(context).viewInsets.bottom), //
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Gaps.vGap50,
                        Text(
                          '${model.expenseItem}',
                          style:
                              TextStyle(fontSize: 20, color: Colours.text_dark),
                        ),
                        Gaps.vGap15,
                        Text(
                          '${model.elderName}   ${model.bedNo}',
                          style: TextStyles.textGray18,
                        ),
                        Gaps.vGap50,
                        ClickItem(
                          title: "执行时间：",
                          content: _selectedTime,
                          onTap: () {
                            _showDateTimePicker(calBack: () {
                              setDialogState(() {
                                _selectedTime = _selectedTime;
                              });
                            });
                          },
                        ),
                        (model.result??[]).length > 0
                            ? Column(
                                children: textFields,
                              )
                            : Gaps.empty,
                        Container(
                          padding: EdgeInsets.all(20),
                          color: Colors.white,
                          alignment: Alignment.topLeft,
                          height: 100,
                          child: TextField(
                            controller: textViewController,
                            maxLines: 5,
                            // maxLength: 300,
                            autofocus: false,
                            decoration: InputDecoration(
                              hintText: "请输入备注内容",
                              hintMaxLines: 20,
                              fillColor: Colours.bg_color,
                              filled: true,
                              border: InputBorder.none,
                            ),
                          ),
                        ),
                        // UploadVoiceWidget((model) {
                        //       voiceFileId = model.id.toString();
                        //     }
                        // ).addToContainer(margin: EdgeInsets.symmetric(horizontal: 16)),
                        AddAndUploadImageWidget(
                              (file,modelList) {
                            files = file;
                          },
                          files: files,
                          max: 3,
                          cameramsg: "拍摄照护执行照片，需要申请您的相机权限",
                          photomsg: "从相册选取照护执行照片，需要申请您的相册权限",
                        ).addToContainer(margin: EdgeInsets.symmetric(horizontal: 8)),
                        Gaps.vGap16,
                        Container(
                          width: double.infinity,
                          height: 50,
                          padding: EdgeInsets.fromLTRB(12, 0, 12, 0),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: <Widget>[
                              FlatsButton(
                                color: Colours.text_gray,
                                onPressed: () {
                                  Navigator.pop(context);
                                },
                                child: Text(
                                  '取消',
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                              FlatsButton(
                                color: Colours.app_main,
                                onPressed: () {
                                  _updateServicePlanRecord(model: model,photoList: files,audioId: voiceFileId);
                                },
                                child: Text(
                                  '确定',
                                  style: TextStyle(color: Colors.white),
                                ),
                              ),
                            ],
                          ),
                        ),
                        Gaps.vGap50,
                      ],
                    ),
                  ),
                ),
                Positioned(
                  left: 20,
                  top: 20,
                  child: FlatsButton(
                    color: Colors.blue[300],
                    onPressed: () {
                      Navigator.pop(context);
                      _bottomDelayServiceSheetAlert(model: model);
                    },
                    child: Text(
                      '延迟执行',
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                ),
              ],
            );
          },
        );
      },
    );

    requestRefresh();
  }

  ///服务执行页 - 直接完成过渡界面
  _bottomServiceDoneSheetAlert(PendingModel model) async {
    _selectedTime = DateTime.now().toDateStr(['yyyy','-','mm','-','dd',' ','HH',':','nn',':','ss']);
    await showModalBottomSheet(
      backgroundColor: Colors.white,
      context: context,
      isScrollControlled: true,
      isDismissible: false,
      builder: (BuildContext context) {
        return ServiceExcuteSubmitWidget(model,delayClick: (model){
          _bottomDelayServiceSheetAlert(
                                model: model, isDoneItem: true);
        },submitClick: (model,isResultMode,photoList,voice,selectTime){
          _selectedTime = selectTime;
          _updateServicePlanRecord(isResultMode: true,photoList: photoList,audioId: voice);

        },);
      },
    );

    requestRefresh();
  }

  ///服务延迟执行页
  _bottomDelayServiceSheetAlert(
      {Key? key, required PendingModel model, bool isDoneItem = false}) {
     showModalBottomSheet(
      backgroundColor: Colors.white,
      context: context,
      isScrollControlled: true,
      isDismissible: false,
      builder: (BuildContext context) {
        return StatefulBuilder(builder: (context, setDialogState) {
          return Stack(
            children: <Widget>[
              SingleChildScrollView(
                child: Container(
                  width: double.infinity,
                  padding: EdgeInsets.only(
                      bottom: MediaQuery.of(context).viewInsets.bottom), //
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Gaps.vGap50,
                      Text(
                        '${model?.expenseItem}',
                        style:
                            TextStyle(fontSize: 20, color: Colours.text_dark),
                      ),
                      Gaps.vGap15,
                      Text(
                        '${model?.elderName}   ${model?.bedNo}',
                        style: TextStyles.textGray18,
                      ),
                      Gaps.vGap50,
                      _serviceDelayItem(
                        '   延迟时间',
                        '$_selectedTime',
                        () {
                          _showDateTimePicker(calBack: () {
                            setDialogState(() {
                              _selectedTime = _selectedTime;
                            });
                          });
                        },
                      ),
                      _serviceDelayItem(
                        '更换执行人',
                        _delayStaff,
                        () {
                          _bottomDelayChangeManagerSheetAlert(() {
                            setDialogState(() {
                              _delayStaff = _delayStaff;
                            });
                          });
                        },
                      ),
                      Gaps.vGap15,
                      Container(
                        padding: EdgeInsets.all(20),
                        color: Colors.white,
                        alignment: Alignment.topLeft,
                        height: 200,
                        child: TextField(
                          controller: textViewController,
                          maxLines: 10,
                          maxLength: 300,
                          autofocus: false,
                          decoration: InputDecoration(
                            hintText: "请输入备注内容",
                            hintMaxLines: 20,
                            fillColor: Colours.bg_color,
                            filled: true,
                            border: InputBorder.none,
                          ),
                        ),
                      ),
                      Gaps.vGap50,
                      Container(
                        width: double.infinity,
                        height: 50,
                        padding: EdgeInsets.fromLTRB(12, 0, 12, 0),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            FlatsButton(
                              color: Colours.text_gray,
                              onPressed: () {
                                Navigator.pop(context);
                              },
                              child: Text(
                                '取消',
                                style: TextStyle(color: Colors.white),
                              ),
                            ),
                            FlatsButton(
                              color: Colours.app_main,
                              onPressed: () {
                                _updateServicePlanRecord(
                                    model: model, isDelayService: true);
                              },
                              child: Text(
                                '确定',
                                style: TextStyle(color: Colors.white),
                              ),
                            ),
                          ],
                        ),
                      ),
                      Gaps.vGap50,
                    ],
                  ),
                ),
              ),
              Positioned(
                left: 20,
                top: 20,
                child: FlatsButton(
                  color: Colors.blue[300],
                  onPressed: () {
                    Navigator.pop(context);
                    if (isDoneItem) {
                      _bottomServiceDoneSheetAlert(model);
                    } else {
                      _bottomServiceSheetAlert(model);
                    }
                  },
                  child: Text(
                    '恢复执行',
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
            ],
          );
        });
      },
    );
  }

  Widget _serviceItem(
      PendingModel model, PendingInfo e, TextEditingController controller) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
          padding: EdgeInsets.fromLTRB(0, 0, 12, 0),
          margin: EdgeInsets.only(left: 15),
          width: ScreenUtil.getScreenW(context),
          decoration: BoxDecoration(
            border: Border(
              bottom: Divider.createBorderSide(context,
                  color: Colours.line, width: 1),
            ),
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Text(
                '${e.subItem}',
                style: TextStyles.textDark18,
              ),
              SizedBox(
                width: 10,
              ),
              Expanded(
                child: TextField(
                  keyboardType: TextInputType.numberWithOptions(decimal: true),
                  textAlign: TextAlign.center,
                  style: TextStyles.textGray18,
                  controller: controller,
                  autofocus: false,
                  inputFormatters: [NumericTextInputFormatter()],
                  decoration: InputDecoration(
                    hintText: "输入${e.subItem}数值",
                    hintStyle: TextStyles.textGray18,
                    fillColor: Colors.white,
                    filled: true,
                    border: InputBorder.none,
                  ),
                ),
              ),
              Text(
                '${model.resultUnit ?? ''}',
                style: TextStyles.textDark18,
              )
            ],
          ),
        ),
        Gaps.vGap15,
        Container(
          padding: EdgeInsets.fromLTRB(15, 0, 15, 15),
          child: Text(
            '正常范围：${e.rangeFrom != "null" ? e.rangeFrom : ""} ~ ${e.rangeTo != "null" ? e.rangeTo : ""}',
            style: TextStyles.textGray14,
          ),
        ),
        Gaps.vGap16,
      ],
    );
  }

  ///调起时间选择器
  void _showDateTimePicker({Key? key, int timeType = 0, VoidCallback? calBack}) {
    dt.DatePicker.showDatePicker(
      context,
      minDateTime: DateTime.parse("1999-01-01"),
      maxDateTime: DateTime.parse("2099-01-01"),
      initialDateTime: _selectedDate,
      dateFormat: timeType == 1 ? DateFormats.y_mo_d : "yyyy-MM-dd EEE,H时:m分",
      locale: dt.DateTimePickerLocale.zh_cn,
      pickerTheme: dt.DateTimePickerTheme(
        showTitle: true,
        cancel: Text("取消"),
        confirm: Text('确定'),
      ),
      pickerMode:
          timeType == 1 ?dt. DateTimePickerMode.date : dt.DateTimePickerMode.datetime,
      // show TimePicker
      onConfirm: (dateTime, List<int> index) {
        if (timeType == 1) {
          _todoTime = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
          if(calBack!=null){
            calBack();
          }

        } else {
          _selectedDate = dateTime;
          this._selectedTime =
              DateUtil.formatDate(dateTime, format: 'yyyy-MM-dd HH:mm:ss');
          if(calBack!=null){
            calBack();
          }
        }
        notifyListeners();
      },
    );
  }

  void _updateServicePlanRecord(
      { PendingModel? model,
      bool isResultMode = false,
      bool isDelayService = false,
      List<String>? photoList,
      String audioId = ""}) {
    ///服务计划=1057
    Map map = {
      'id': _bizId,
      'executeStatus': isDelayService ? 1 : 0,
      "remark": textViewController.text ?? "",
    };

    if(photoList!=null){
      map['photoList'] = photoList;
      map['photoIds'] = photoList.join(",");
    }
    if(!audioId.isNullOrEmpty()){
      map['audioId'] = audioId;
    }
    if (isDelayService) {
      if (TextUtil.isEmpty(_selectedTime) && _humanId == null) {
        showToast('延迟时间和执行人不能同时为空');
        return;
      }
      if (!TextUtil.isEmpty(textViewController.text)) {
        map['remark'] = textViewController.text;
      }
      if (!TextUtil.isEmpty(_selectedTime)) {
        map['delayTime'] = _selectedTime;
      }
      if (_humanId != null) {
        map['changeExecutorId'] = _humanId;
      }
    } else {
      map['finishTime'] = _selectedTime != null ? _selectedTime : "";
      if (isResultMode == false) {
        var temp = [];
        var indexList = <int>[];
        for (var i = 0; i <( model?.result??[]).length; i++) {
          temp.add({
            'value': textEditingControllers[i].text,
            'rangeTo':
                model!.result![i].rangeTo != null ? model.result![i].rangeTo : "",
            'rangeFrom': model.result![i].rangeFrom != null
                ? model.result![i].rangeFrom
                : "",
            'subItem': model.result![i].subItem,
          });
          if(textEditingControllers[i].text.isNullOrEmpty()){
            indexList.add(i);
          }
        }
        map['result'] = jsonEncode(temp);
        if(indexList.isNotEmpty){
          showToast("请填写${model!.result![indexList[0]].subItem}数据");
          return;
        }
      }
    }

    Map map1 = new Map<String, dynamic>.from(map);
    showLoadingDialog();
    HttpUtil.instance
        .getDio()
        .post('${HttpApi.updateServicePlanRecord}',data: map1.toJsonMapStr(),options: Options(contentType: Headers.formUrlEncodedContentType))
        .then((r) {
      hideDialog();
      if (r.statusCode == 200) {
        Map<String, dynamic> map = json.decode(r.toString());
        //
        if (map["code"].toString() == "0") {
          showToast(map["msg"]);
          onRefresh();
          Navigator.pop(context);
        } else {
          showToast(map["msg"]);
        }
      } else {
        showToast(r.statusCode.toString());
      }
    }).catchError((e) {
      hideDialog();
      print(e.toString());
      showToast(getErrorMessage((e as DioError).type));
    });
  }

  Widget _serviceDelayItem(String title, String content, Function() onTap) {
    return GestureDetector(
      onTap: onTap,
      behavior: HitTestBehavior.opaque,
      child: Container(
        padding: EdgeInsets.fromLTRB(0, 15, 15, 15),
        margin: EdgeInsets.only(left: 15),
        width: ScreenUtil.getScreenW(context),
        decoration: BoxDecoration(
          border: Border(
            bottom: Divider.createBorderSide(context,
                color: Colours.line, width: 1),
          ),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Text(
              '$title',
              style: TextStyles.textDark18,
            ),
            SizedBox(
              width: 10,
            ),
            Expanded(
              child: Text(
                '$content',
                textAlign: TextAlign.center,
                style: TextStyles.textDark18,
              ),
            ),
            LoadAssetImage(
              'ic_arrow_right',
              width: 25,
              height: 45,
            ),
          ],
        ),
      ),
    );
  }


  ///服务小组列表
  _fectserviceGroupData() {
    HttpUtil.instance.getDio().post(HttpApi.getAllByCurBranch).then((r) {
      if (r.statusCode == 200) {
        Map<String, dynamic> map = json.decode(r.toString());
        if (map["code"].toString() == "0") {
          if (map['data'] != null) {
            StaffGroupEntity model = StaffGroupEntity.fromJson(map);
            if ((model.data??[]).length > 0) {
              model.data!.first.isSelected = true;
              staffGroupList = model.data!;
              _serviceTypeId = model.data!.first.serviceTypeId!;
              _fectserviceStaffData(null);
              notifyListeners();
            }
          } else {
            showToast(map["msg"]);
          }
        } else {
          showToast(map["msg"]);
        }
      } else {
        showToast(r.statusCode.toString());
      }
    }).catchError((e) {
      print(e.toString());
      showToast(getErrorMessage((e as DioError).type));
    });
  }

  ///更换执行人
  _bottomDelayChangeManagerSheetAlert(VoidCallback callback) async {
    await showModalBottomSheet(
      backgroundColor: Colors.white,
      context: context,
      isScrollControlled: true,
      isDismissible: false,
      builder: (BuildContext context) {
        return StatefulBuilder(builder: (context, setDialogState) {
          return Stack(
            children: <Widget>[
              Container(
                height: ScreenUtil.getScreenH(context) * 2 / 3,
                padding: EdgeInsets.only(top: 90),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Container(
                      width: ScreenUtil.getScreenW(context) * 0.3,
                      color: Colors.white,
                      child: ListView.separated(
                        itemCount: staffGroupList.length,
                        itemBuilder: (_, int index) {
                          return GestureDetector(
                            onTap: () {
                              if (staffGroupList[index].serviceTypeId ==
                                  _serviceTypeId) {
                                return;
                              }
                              for (int i = 0; i < staffGroupList.length; i++) {
                                if (i == index) {
                                  staffGroupList[i].isSelected = true;
                                } else {
                                  staffGroupList[i].isSelected = false;
                                }
                              }
                              setDialogState(() {
                                _serviceTypeId =
                                    staffGroupList[index].serviceTypeId!;
                                staffList = [];
                                _fectserviceStaffData(setDialogState);
                              });
                            },
                            child: Container(
                              color: staffGroupList[index].isSelected
                                  ? Colours.bg_color
                                  : Colors.white,
                              alignment: Alignment.center,
                              height: 60,
                              child: Text(
                                staffGroupList[index].name??"",
                                style: TextStyle(
                                  color: Colors.black,
                                  fontSize: 16,
                                ),
                              ),
                            ),
                          );
                        },
                        separatorBuilder: (context, int) {
                          return Container(
                            width: double.infinity,
                            color: Colours.line,
                            height: 1,
                          );
                        },
                      ),
                    ),
                    Container(
                      width: 1,
                      color: Colours.line,
                      height: ScreenUtil.getScreenH(context),
                    ),
                    Container(
                      width: ScreenUtil.getScreenW(context) * 0.7 - 1,
                      color: Colours.bg_color,
                      child: ListView.separated(
                        itemCount: staffList.length,
                        itemBuilder: (_, int index) {
                          return GestureDetector(
                            onTap: () {
                              setDialogState(() {
                                _delayStaff = staffList[index].userName??"";
                                _humanId = staffList[index].humanId;
                              });
                            },
                            behavior: HitTestBehavior.opaque,
                            child: Container(
                              padding: EdgeInsets.all(15),
                              color: Colors.white,
                              child: Text(
                                '${staffList[index].userName}',
                                textAlign: TextAlign.center,
                              ),
                            ),
                          );
                        },
                        separatorBuilder: (context, int) {
                          return Container(
                            width: ScreenUtil.getScreenW(context),
                            color: Colours.line,
                            height: 1,
                          );
                        },
                      ),
                    )
                  ],
                ),
              ),
              Positioned(
                left: 20,
                top: 20,
                child: FlatsButton(
                  color: Colours.text_gray,
                  onPressed: () {
                    Navigator.pop(context);
                  },
                  child: Text(
                    '取消',
                    style: TextStyle(color: Colours.text_dark),
                  ),
                ),
              ),
              Positioned(
                right: 20,
                top: 20,
                child: FlatsButton(
                  color: Colors.blue[300],
                  onPressed: () {
                    callback();
                    Navigator.pop(context);
                  },
                  child: Text(
                    '确定',
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              Positioned(
                right: 0,
                left: 0,
                top: 90,
                child: Gaps.line,
              ),
              Positioned(
                right: 200.0,
                left: 200.0,
                top: 35,
                child: Text(
                  '$_delayStaff',
                  textAlign: TextAlign.center,
                  style: TextStyles.textDark18,
                ),
              ),
            ],
          );
        });
      },
    );
    requestRefresh();
  }

  ///服务小组组员列表
  _fectserviceStaffData(void Function(void Function())? setDialogState) {
    showLoadingDialog();
    var map = {'serviceGroupId': _serviceTypeId};
    HttpUtil.instance
        .getDio()
        .post(HttpApi.listByGroupId, data: map,options: PostRequest.urlencodedHeader)
        .then((r) {
      hideDialog();
      if (r.statusCode == 200) {
        Map<String, dynamic> map = json.decode(r.toString());
        //
        if (map["code"].toString() == "0") {
          if (map['data'] != null) {
            StaffGroupEntity model = StaffGroupEntity.fromJson(map);
            if ((model.data??[]).length > 0) {
              if (setDialogState != null) {
                setDialogState(() {
                  staffList = model.data!;
                });
              } else {
                staffList = model.data!;
              }
            }
          } else {
            showToast(map["msg"]);
          }
        } else {
          showToast(map["msg"]);
        }
      } else {
        showToast(r.statusCode.toString());
      }
    }).catchError((e) {
      hideDialog();
      print(e.toString());
      showToast(getErrorMessage((e as DioError).type));
    });
  }

  void onRefresh() {}

  @override
  void onCreated() {
    super.onCreated();
    _fectserviceGroupData();
  }
}
